<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript">
            function showHint(str) {
                var xmlhttp;
                if (str.length === 0) {
                    document.getElementById("txtHint").innerHTML = "";
                    return;
                }
                if (!xmlhttp) {
                    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp = new XMLHttpRequest();
                    } else {// code for IE6, IE5
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                }
                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
                        document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                    }
                };
                //xmlhttp.open("GET", "/W001/c001/a006?q=" + str, true);
                xmlhttp.open("POST", "/W001/c001/a006", true);
                xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xmlhttp.send("q=" + str);
            }
        </script>
    </head>
    <body>
        <h3>请在下面的输入框中键入字母（A - Z）：4</h3>
        <form action=""> 
            姓氏：<input type="text" id="txt1" onkeyup="showHint(this.value)" />
        </form>
        <p>建议：<span id="txtHint"></span></p> 
    </body>
</html>
